package labReport.experiment2;

class Dog {
    private int weight;

    public int getWeight() {
        return weight;
    }

    public void setWeight(int weight) {
        this.weight = weight;
    }

    public Dog(int weight) {
        this.weight = weight;
        System.out.println("使用有参数的构造方法,狗的体重为：" + weight +"公斤");
    }

    public Dog() {
        System.out.print("使用无参数的构造方法,");
    }
}

public class DogTest {
    public static void main(String[] args) {
        Dog dog_teddy = new Dog();
        dog_teddy.setWeight(5);
        System.out.println("狗的体重为：" + dog_teddy.getWeight() + "公斤");
        Dog dog_husky = new Dog(20);

    }
}
